package com.runshu.config;

import com.runshu.rest.RestClient;
import com.runshu.rest.RestClientImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Rest请求全局配置
 *
 * @author dhs
 * @date 2020-05-06
 */
@Configuration
public class HttpclientConfig {

    // 最大错误数
    private final int executionCount = 5;

    // 连接池最大生成连接数
    private final int connectionMaxTotal = 200;

    // 默认设置route最大连接数 如访问一个域名最多
    private final int connectionDefaultMaxPerRoute = 50;

    @Bean
    public RestClient restClient() {
        //初始化调用客户端
        RestClient restClient = new RestClientImpl(executionCount, connectionMaxTotal, connectionDefaultMaxPerRoute);
        return restClient;
    }

}
